/**
 *
 * @param {*} str strign,Array, number
 */
import { ROLE } from "config/index";
import _ from "lodash";

function getRoleMap() {
  let role_map: any = {};
  ROLE.forEach((item) => {
    role_map[item.key] = item;
  });
  return role_map;
}

export function getAuthority(str?: number) {
  let id = localStorage.getItem('userAuth') ? JSON.parse(localStorage.getItem('userAuth') as string).roleId : ''
  const map = getRoleMap()
  return str ? map[str]?.authority: map[id]?.authority
}
